<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>添加/编辑分类</title>
<link href="__PUBLIC__/admin/css/xc.min.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/xc.admin.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.js"></script> 
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/common-1.0.js"></script> 

</head>
<body>
<div class="pd-10">
  <form action="" method="post" class="form form-horizontal" id="myform">
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>分类名称：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" id="cname" name="cname" placeholder="请输入分类名称" value="{$re.ca_name}">
      </div>
    </div>
<!--    <div class="row cl">-->
<!--      <label class="form-label col-3"><span class="c-red">*</span>分类等级：</label>-->
<!--      <div class="formControls col-8">-->
<!--        <span class="select-box"><select class="select" id="level" name="level">-->
<!--          <option value="0" <if condition="($re[ca_parent] eq 0)">selected</if>>顶级分类</option>-->
<!--          <volist name='calist' id='cvo'>-->
<!--            <option value="{$cvo.ca_id}" <if condition="($re[ca_parent] eq $cvo[ca_id])">selected</if>>{$cvo.ca_name}</option>          -->
<!--          </volist>-->
<!--        </select></span>-->
<!--      </div>-->
<!--    </div>-->
    <!--<div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>涉及品牌：</label>
      <div class="formControls col-8 skin-minimal">
        <volist name='brlist' id='bvo'><div class="check-box">
          <input type="checkbox" class="input-text" id="brid{$bvo.br_id}" name="brid[]" <if condition='($bvo[enable] eq 1)'>checked</if> value="{$bvo.br_id}"><label for="brid{$bvo.br_id}">{$bvo.br_name}</label>
        </div></volist>
      </div>
    </div>-->
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>缩略图：</label>
      <div class="formControls col-6"> <span class="btn-upload form-group">
        <input class="input-text upload-url" type="text" id="adImgUrl" name="adImgUrl" readonly style="width:250px" value="{$re.ca_thumb}" placeholder="请上传图像文件" />
        <a href="javascript:;" class="a-upload" onchange="uploadImage('myfile','cate','ad');"><input type="file" name="myfile" id="myfile" alt="上传文件">点击上传文件</a>	
        </span><br/><font color="#f00">*请上传120X120px图片</font>
      </div>
      <div class="formControls col-2">
        <img id="adImg" src="__UPLOAD__/{$re.ca_thumb|default='img/no_image.jpg'}" style="width:100px; height:100px; float: left">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>分类排序：</label>
      <div class="formControls col-8">
        <input type="text" class="input-text" id="sort" name="sort" value="{$re.ca_sort|default='50'}">
      </div>
    </div>
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <input type="hidden" id="cid" name="cid" value="{$re.ca_id}">
        <button type="button" id="sub" name="sub" class="btn btn-primary radius" onClick="checkSubmit()"><i class='Hui-iconfont'>&#xe632;</i> 保存</button>
        <button class="btn btn-default radius" type="button" onClick="layer_close();"><i class='Hui-iconfont'>&#xe66b;</i> 取消</button>
      </div>
    </div>
  </form>
</div>
<script type="text/javascript">
//按回车件触发提交
document.onkeydown=function(event){
	var e = event || window.event || arguments.callee.caller.arguments[0];
	if(e && e.keyCode==13){ // enter 键
		checkSubmit();
	}
}; 
//提交数据
function checkSubmit()
{
	var cname = $.trim($('#cname').val());
	var level = $.trim($('#level').val());
	//var brlen = $("input[type='checkbox']:checked").length;
	if(cname == ''){
		layer.msg('分类名称不能为空', {icon: 2});
		return false;
	}
	// if(level == ''){
	// 	layer.msg('分类等级未选择', {icon: 2});
	// 	return false;
	// }
	//if(brlen=='0'){
//		layer.msg('涉及品牌未选择', {icon: 2});
//		return false;
//	}
	$.ajax({
		type : 'post',
		url : '__MODULE__/Goods/cateAddEdit',
		data : $("#myform").serialize(),
		dataType : 'json',
		success : function(res){
			if(res.status == 1){
				layer.msg(res.msg,{icon:1,time:4000},function(){
					// 先获取窗口索引，才能关闭窗口  
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				});
			   window.parent.location.reload(); //刷新父页面
			}else{
				layer.msg(res.msg, {icon: 2});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.alert('网络失败，请刷新页面后重试',{icon:2});
		}
	})
}
</script>
<!-- 单选 复选框 -->
<link href="__PUBLIC__/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/lib/icheck/jquery.icheck.min.js"></script>
<script type="text/javascript">
$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
});
</script>
<!-- 单选 复选框 -->
</body>
</html>